#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<qpainter.h>
#include"mypushbutton.h"
#include<QDebug>
#include<QTimer>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setFixedSize(1211,800);
   // setWindowIcon(QIcon("文件名"));设置标题图标
    setWindowTitle("火柴人不能死");
    connect(ui->actionq,&QAction::triggered,[=](){
        this->close();
    });
//开始按钮
    mypushbutton*startBtn=new mypushbutton("://picture/start.png");
    startBtn->setParent(this);
    startBtn->move(this->width()*0.5-startBtn->width()*0.5,this->height()*0.7);
// 实例化选择关卡场景
    game=new gamescene;
//弹跳特效
    connect(startBtn,&mypushbutton::clicked,[=](){
        startBtn->zoom1();
        startBtn->zoom2();

    //进入另一个场景
    //添加延时进入
        QTimer::singleShot(500,this,[=](){    this->hide();
            game->show();game->startmoving();
        });


 });

}
void MainWindow:: paintEvent(QPaintEvent*){
    QPainter painter(this);
    QPixmap pix;
    pix.load("://picture/least.jpg");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);//拉伸成窗口大小

}
MainWindow::~MainWindow()
{
    delete ui;
}
